Schema Map
Schema is an object that notion uses to define the structure of a database. It looks something like this
Parts of a schema#
- schema_id: The schema id is the key used to store the schema, the schema ids in the above schema object are
LXecandtitle. - name: The name stores the name of the column/property/schema_unit
- type: The type key contains the type of data stored.
Schema Map#
To verify and obtain the property referenced in the formula, all the exposed methods expect an optional second argument that is a map of the schema hence named schema map.
It has the following structure
schema_id: stringname: stringtype: TSchemaUnitType
Different schema_map structure
Schema Unit types like multi_select, select, formula, and relation, rollup are a bit more complex than the above mentioned structure
Example#
Lets see an example of a simple schema_map:
JS
TS
Notice the syntax used to create a map. The Map constructor takes an array of entries, where the first item is the key and the second item is the value stored in that particular key.
Name and Key
Remember to keep the name and the key of each entries the same. For example this wont work
Creation#
There are two ways you can create a schema_map
- You can create a schema_map manually, using the
Mapconstructor - You can use the
@nishans/utilspackage to create aschema_mapdynamically from the remote schema.
JS
TS